#include <opencv2\opencv.hpp>
using namespace cv;
int main()
{
	Mat img = imread("affine.jpg");
	Mat dst;
	Mat roi1 = img(Range(45, 55), Range(45, 55));
	Mat roi2 = img(Range(195, 205), Range(45, 55));
	Mat roi3 = img(Range(45, 55), Range(195, 205));
	roi1 = Scalar(255, 0, 0);
	roi2 = Scalar(0, 255, 0);
	roi3 = Scalar(0, 0, 255);
	Mat pts1 = (Mat_<float>(3, 2) << 50, 50, 200, 50, 50, 200);
	Mat pts2 = (Mat_<float>(3, 2) << 10, 100, 200, 50, 100, 250);
	Mat M = getAffineTransform(pts1, pts2);
	warpAffine(img, dst, M, Size(img.cols, img.rows));
	imshow("img", img);
	imshow("dst", dst);
	waitKey(0);
	return 0;
}